<?php
/**
 * 客户
 */

namespace app\badmin\controller;


use app\badmin\model\AgentFollowLog;
use app\badmin\model\AgentUserDemand;
use app\badmin\model\AgentUserInteractionLog;
use app\badmin\model\CompanyAgentUser;
use app\badmin\model\CompanyLoanConsult;
use app\badmin\model\CompanyUser as CompanyUserModel;
use app\common\controller\BadminController;
use think\Exception;

class CompanyUser extends BadminController {

    /**
     * 客户列表
     * @return false|string
     */
    public function getList() {
        try {
            $params = $this->checkParams('');
            if ($params === false) return $this->resErr();
            $res = CompanyUserModel::getList($params);
            return $this->resData('success', $res);
        } catch (Exception $e) {
            return $this->resErr($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 购房需求
     * @return false|string
     */
    public function userDemand() {
        try {
            $params = $this->checkParams('id');
            if ($params === false) return $this->resErr();
            $res = AgentUserDemand::userDemand($params, $data);
            if (!$res) return $this->resErr();
            else return $this->resData('success', $data);
        } catch (Exception $e) {
            return $this->resErr($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 贷款需求
     * @return false|string
     */
    public function companyLoanConsult() {
        try {
            $params = $this->checkParams('id');
            if ($params === false) return $this->resErr();
            $res = CompanyLoanConsult::companyLoanConsult($params);
            return $this->resData('success', $res);
        } catch (Exception $e) {
            return $this->resErr($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 客户详情
     * @return false|string
     */
    public function userInfo() {
        try {
            $params = $this->checkParams('id,page1,long1,page2,long2,page3,long3');
            if ($params === false) return $this->resErr();
            $res['info'] = CompanyAgentUser::userInfo($params);//客户详情
            $res['interaction_log'] = AgentUserInteractionLog::interaction_log($params);//互动记录
            $res['house_log'] = AgentUserInteractionLog::house_log($params);//房源记录
            $res['follow_log'] = AgentFollowLog::follow_log($params);//跟进记录
            return $this->resData('success', $res);
        } catch (Exception $e) {
            return $this->resErr($e->getMessage(), $e->getCode());
        }
    }


}